package com.tubi.Set;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetDemo1 {
    public static void main(String[] args) {
        TreeSet<Teacher> ts = new TreeSet<>(new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int result = o1.getAge()-o2.getAge();
                result=result == 0? o1.getName().compareTo(o2.getName()):result;
                return  result;
            }
        });
        Teacher ronglei = new Teacher("ronglei", 12);
        Teacher rongle = new Teacher("rongle", 112);
        Teacher rongl = new Teacher("rongl", 172);
        ts.add(ronglei);
        ts.add(rongle);
        ts.add(rongl);
        System.out.println(ts);
    }
}
